﻿using System.Reflection;
using Abp.Modules;
using Abp.AutoMapper;
using AVIS.OutBound.WizardAgent;
using AVIS.OutBound.CarGroups;
using AVIS.OutBound.Contents.Cache;
using AVIS.OutBound.Contents;
using AVIS.OutBound.Infrastructure;

namespace AVIS.OutBound
{
    [DependsOn(
        typeof(AbpAutoMapperModule),
        typeof(OutBoundWizardAgentModule),
        typeof(OutBoundInfrastructureModule)
    )]
    public class OutBoundCoreModule : AbpModule
    {
        public override void PreInitialize()
        {
            // 配置对象映射的关系
            Configuration.Modules.AbpAutoMapper().Configurators.Add(config =>
            {
                // 车组（【Wizard】CarGroupDto -> CarGroup）
                config.CreateMap<CarGroupDto, CarGroup>()
                      .ForMember(u => u.ModelCode, options => options.MapFrom(input => input.ModelName.Substring(6, 2).Trim())); // 车组编号
            });
        }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
        }
    }
}
